/******************************************************************************
	Implementation of II_Meter Custom Control class

	(C) Copyright 2007. Ian Sanderson
		All rights reserved.
 ******************************************************************************/

#include	"stdafx.h"
#include	"ii_meter.h"

using		namespace		II_Controls;

//	 II_Meter properties

Color	II_Meter::GetBackColor	()
{
	return	BackColor;
}

void	II_Meter::SetBackColor	(Color propVal)
{
	BackColor		=	propVal;

	Invalidate ();
}

Color	II_Meter::GetForeColor	()
{
	return	ForeColor;
}

void	II_Meter::SetForeColor	(Color propVal)
{
	ForeColor		=	propVal;

	Invalidate ();
}

void	II_Meter::OnPaint	(
			 PaintEventArgs^	e
			 )
{
	Rectangle	Rb, Rf;
	float		Proportion;

		Rb				=	this -> ClientRectangle;
		Rf				=	Rb;

		Proportion		=	(float) NPosition / ((float) NMaxPosition - (float) NMinPosition);
		Rf.Width		=	(int) (Proportion * (float) Rb.Width);

	SolidBrush^	b		=	gcnew	SolidBrush (BackColor);
		e->Graphics->FillRectangle (b, Rb);

		b->Color		=	ForeColor;
		e->Graphics->FillRectangle (b, Rf);

		delete	b;
}